#!/usr/bin/env python

import threading


class Singleton(object):
	def __init__():
   		"disable the __init__ method"

	__inst = None # make it so-called private

	__lock = threading.Lock() # used to synchronize code

	@staticmethod
	def getInst(class_arg, **args):
		Singleton.__lock.acquire()
		if not Singleton.__inst:
			Singleton.__inst = class_arg(**args)
		Singleton.__lock.release()
		return Singleton.__inst

if __name__ == '__main__':

	class X(object):
		inner_value = 1
		def __init__(self, **args):
			self.inner_value = 100

	a = Singleton.getInst(X, a = 'a')
	print a.inner_value
